import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/11 11:29
 */

class ListNode{
    int val;
    ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}

public class Solution {
    public ListNode swapPairs(ListNode head) {
        if(head == null || head.next == null) return head;

        ListNode tmp = swapPairs(head.next.next);
        ListNode ret = head.next;
        ret.next = head;
        head.next = tmp;

        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int len = in.nextInt();
            ListNode head = null;
            ListNode tail = null;
            for (int i = 0; i < len; i++) {
                int val = in.nextInt();
                ListNode newHead = new ListNode(val);
                if(head == null){
                    head = newHead;
                    tail = newHead;
                }else {
                    tail.next = newHead;
                    tail = newHead;
                }
            }
            Solution solution = new Solution();
            ListNode ret = solution.swapPairs(head);
            ListNode cur = ret;
            while(cur != null){
                System.out.print(cur.val+" ");
                cur = cur.next;
            }
        }
    }
}